@@ -3,6 +3,7 @@ |
||
3 | 3 |
from django_logit import logit |
4 | 4 |
from django_response import response |
5 | 5 |
from paginator import pagination |
6 |
+from TimeConvert import TimeConvert as tc |
|
6 | 7 |
|
7 | 8 |
from thermometer.models import ThermometerInfo |
8 | 9 |
|
@@ -12,7 +13,9 @@ def thermometer_bind(request): |
||
12 | 13 |
user_id = request.POST.get('user_id', '') |
13 | 14 |
macid = request.POST.get('macid', '') |
14 | 15 |
|
15 |
- ThermometerInfo.objects.get_or_create(user_id=user_id, macid=macid) |
|
16 |
+ thermometer, _ = ThermometerInfo.objects.get_or_create(user_id=user_id, macid=macid) |
|
17 |
+ thermometer.bound_at = tc.utc_datetime() |
|
18 |
+ thermometer.save() |
|
16 | 19 |
|
17 | 20 |
return response() |
18 | 21 |
|
@@ -4,12 +4,14 @@ from django.db import models |
||
4 | 4 |
from django.utils.translation import gettext_lazy as _ |
5 | 5 |
from django_models_ext import BaseModelMixin |
6 | 6 |
from shortuuidfield import ShortUUIDField |
7 |
+from TimeConvert import TimeConvert as tc |
|
7 | 8 |
|
8 | 9 |
|
9 | 10 |
class ThermometerInfo(BaseModelMixin): |
10 | 11 |
thermometer_id = ShortUUIDField(_('thermometer_id'), max_length=32, blank=True, null=True, help_text='体温计唯一标识', db_index=True, unique=True) |
11 | 12 |
user_id = models.CharField(_('user_id'), max_length=32, blank=True, help_text='用户唯一标识', db_index=True) |
12 | 13 |
macid = models.CharField(_('macid'), max_length=32, blank=True, null=True, help_text='设备号') |
14 |
+ bound_at = models.DateTimeField(_('bound_at'), blank=True, null=True, help_text='绑定时间') |
|
13 | 15 |
|
14 | 16 |
class Meta: |
15 | 17 |
verbose_name = _('体温计信息') |
@@ -24,4 +26,5 @@ class ThermometerInfo(BaseModelMixin): |
||
24 | 26 |
'thermometer_id': self.thermometer_id, |
25 | 27 |
'user_id': self.user_id, |
26 | 28 |
'macid': self.macid, |
29 |
+ 'bound_at': tc.local_string(utc_dt=self.bound_at), |
|
27 | 30 |
} |